
<!DOCTYPE html>
<html lang="zh-CN" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>地形系统Shader学习 - 浪子之心</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="Blog,"> 
    <meta name="description" content="MrChen Bolg,基于混合因子的地形材质混合取第一套UV
取第一层材质的数据同样取出其他的材质， layer2，layer3.
使用顶点色材质的使用量HeightLerp输入Height  从高度图采样的高度Tran,"> 
    <meta name="author" content="Jack Chen"> 
    <link rel="alternative" href="atom.xml" title="浪子之心" type="application/atom+xml"> 
    <link rel="icon" href="/blog/img/favicon.png"> 
    
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">

    
<link rel="stylesheet" href="/blog/css/diaspora.css">

<meta name="generator" content="Hexo 5.4.1"><link rel="stylesheet" href="/blog/css/prism.css" type="text/css"></head>

<body class="loading">
    <span id="config-title" style="display:none">浪子之心</span>
    <div id="loader"></div>
    <div id="single">
    <div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <a class="iconfont icon-home image-icon" href="javascript:;" data-url="https://mrchenlearnspace.github.io/blog"></a>
    <div title="播放/暂停" class="iconfont icon-play"></div>
    <h3 class="subtitle">地形系统Shader学习</h3>
    <div class="social">
        <div>
            <div class="share">
                <a title="获取二维码" class="iconfont icon-scan" href="javascript:;"></a>
            </div>
            <div id="qr"></div>
        </div>
    </div>
    <div class="scrollbar"></div>
</div>

    <div class="section">
        <div class="article">
    <div class='main'>
        <h1 class="title">地形系统Shader学习</h1>
        <div class="stuff">
            <span>七月 08, 2022</span>
            
  <ul class="post-tags-list" itemprop="keywords"><li class="post-tags-list-item"><a class="post-tags-list-link" href="/blog/tags/Shader/" rel="tag">Shader</a></li></ul>


        </div>
        <div class="content markdown">
            <h1 id="基于混合因子的地形材质混合"><a href="#基于混合因子的地形材质混合" class="headerlink" title="基于混合因子的地形材质混合"></a>基于混合因子的地形材质混合</h1><h2 id="取第一套UV"><a href="#取第一套UV" class="headerlink" title="取第一套UV"></a>取第一套UV</h2><p><img src="https://img-blog.csdnimg.cn/ac02382463784ee9a47d5a460dae9e76.png" alt="在这里插入图片描述"></p>
<h2 id="取第一层材质的数据"><a href="#取第一层材质的数据" class="headerlink" title="取第一层材质的数据"></a>取第一层材质的数据</h2><p><img src="https://img-blog.csdnimg.cn/33a4fe5dbc4f490393ecd64005c1ce81.png" alt="在这里插入图片描述"><br>同样取出其他的材质， layer2，layer3.</p>
<h2 id="使用顶点色材质的使用量"><a href="#使用顶点色材质的使用量" class="headerlink" title="使用顶点色材质的使用量"></a>使用顶点色材质的使用量</h2><p>HeightLerp<br>输入<br>Height  从高度图采样的高度<br>Transition 用来控制材质使用量的参数，一般使用顶点色的4个通道<br>BlendContrast 混合对比度，数值越大对比越明显<br>输出<br>得到一个基于高度的混合因子<br><img src="https://img-blog.csdnimg.cn/ba25f83805064ed2adea8881cf4f5250.png" alt="在这里插入图片描述"><br>混合因子的制作<br><img src="https://img-blog.csdnimg.cn/10a69305174d48c8a495ea10cf82033d.png" alt="在这里插入图片描述"></p>
<h2 id="将三种材质混合"><a href="#将三种材质混合" class="headerlink" title="将三种材质混合"></a>将三种材质混合</h2><p>以基础颜色为例<br><img src="https://img-blog.csdnimg.cn/40b9391dc62447778cf01baa4ca4c0f3.png" alt="在这里插入图片描述"><br>粗糙度，AO，法线同上一样。</p>
<h2 id="效果Combine"><a href="#效果Combine" class="headerlink" title="效果Combine"></a>效果Combine</h2><p><img src="https://img-blog.csdnimg.cn/6c64aaad722d488fb9645d0b22662eef.png" alt="在这里插入图片描述"><br>通过修改顶点色RGB就能混合材质了<br><img src="https://img-blog.csdnimg.cn/ae83a279952341d3b3b7409d0c36c5b4.png" alt="在这里插入图片描述"></p>
<h1 id="基于权重的地形材质混合"><a href="#基于权重的地形材质混合" class="headerlink" title="基于权重的地形材质混合"></a>基于权重的地形材质混合</h1><h2 id="混合权重的制作"><a href="#混合权重的制作" class="headerlink" title="混合权重的制作"></a>混合权重的制作</h2><p>取最大值，最大值减去混合对比度，用原值减去混合对比度的差，同时保证数据不为负数，然后除以三值的和就行。<br><img src="https://img-blog.csdnimg.cn/f4168fd4d18047169d7bf1965f231e9f.png" alt="在这里插入图片描述"></p>
<h2 id="将三种材质混合-1"><a href="#将三种材质混合-1" class="headerlink" title="将三种材质混合"></a>将三种材质混合</h2><p>因为是权重，且和等于一所以效果可以直接叠加。<br><img src="https://img-blog.csdnimg.cn/dec07982ef384663a79a636b70de13bc.png" alt="在这里插入图片描述"><br>粗糙度，AO，法线同上一样。</p>
<h1 id="用权重图代替顶点色"><a href="#用权重图代替顶点色" class="headerlink" title="用权重图代替顶点色"></a>用权重图代替顶点色</h1><p>使用插件paint in 3D插件实时绘制好权重图并替换顶点色</p>
<h1 id="注意事项"><a href="#注意事项" class="headerlink" title="注意事项"></a>注意事项</h1><p><strong>顶点色要保证权重之和小于等于1。<br>确保使用的UV是地形一套的UV</strong><br>地形模型边缘悬崖可以用插值方法代替材质。</p>
<p>​    </p>

            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls" data-autoplay="false">
                <source type="audio/mpeg" src="/music/jucilang.mp3">
            </audio>
            
        </div>
        
    <div id='gitalk-container' class="comment link"
		data-enable='true'
        data-ae='true'
        data-ci='99f95a936c6fcdb1bd67'
        data-cs='c2d1bba3d6b7f9ade4f3de09a63925bd837c25ea'
        data-r='mrchenlearnspace.github.io'
        data-o='MrChenLearnSpace'
        data-a='MrChenLearnSpace'
        data-d='false'
    >查看评论</div>


    </div>
    
        <div class='side'>
			<ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9F%BA%E4%BA%8E%E6%B7%B7%E5%90%88%E5%9B%A0%E5%AD%90%E7%9A%84%E5%9C%B0%E5%BD%A2%E6%9D%90%E8%B4%A8%E6%B7%B7%E5%90%88"><span class="toc-number">1.</span> <span class="toc-text">基于混合因子的地形材质混合</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%96%E7%AC%AC%E4%B8%80%E5%A5%97UV"><span class="toc-number">1.1.</span> <span class="toc-text">取第一套UV</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%96%E7%AC%AC%E4%B8%80%E5%B1%82%E6%9D%90%E8%B4%A8%E7%9A%84%E6%95%B0%E6%8D%AE"><span class="toc-number">1.2.</span> <span class="toc-text">取第一层材质的数据</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8%E9%A1%B6%E7%82%B9%E8%89%B2%E6%9D%90%E8%B4%A8%E7%9A%84%E4%BD%BF%E7%94%A8%E9%87%8F"><span class="toc-number">1.3.</span> <span class="toc-text">使用顶点色材质的使用量</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B0%86%E4%B8%89%E7%A7%8D%E6%9D%90%E8%B4%A8%E6%B7%B7%E5%90%88"><span class="toc-number">1.4.</span> <span class="toc-text">将三种材质混合</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%88%E6%9E%9CCombine"><span class="toc-number">1.5.</span> <span class="toc-text">效果Combine</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9F%BA%E4%BA%8E%E6%9D%83%E9%87%8D%E7%9A%84%E5%9C%B0%E5%BD%A2%E6%9D%90%E8%B4%A8%E6%B7%B7%E5%90%88"><span class="toc-number">2.</span> <span class="toc-text">基于权重的地形材质混合</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B7%B7%E5%90%88%E6%9D%83%E9%87%8D%E7%9A%84%E5%88%B6%E4%BD%9C"><span class="toc-number">2.1.</span> <span class="toc-text">混合权重的制作</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B0%86%E4%B8%89%E7%A7%8D%E6%9D%90%E8%B4%A8%E6%B7%B7%E5%90%88-1"><span class="toc-number">2.2.</span> <span class="toc-text">将三种材质混合</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%94%A8%E6%9D%83%E9%87%8D%E5%9B%BE%E4%BB%A3%E6%9B%BF%E9%A1%B6%E7%82%B9%E8%89%B2"><span class="toc-number">3.</span> <span class="toc-text">用权重图代替顶点色</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9"><span class="toc-number">4.</span> <span class="toc-text">注意事项</span></a></li></ol>	
        </div>
    
</div>


    </div>
</div>
</body>

<script src="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>


<script src="//lib.baomitu.com/jquery/1.8.3/jquery.min.js"></script>
<script src="/blog/js/plugin.js"></script>
<script src="/blog/js/typed.js"></script>
<script src="/blog/js/diaspora.js"></script>


<link rel="stylesheet" href="/blog/photoswipe/photoswipe.css">
<link rel="stylesheet" href="/blog/photoswipe/default-skin/default-skin.css">


<script src="/blog/photoswipe/photoswipe.min.js"></script>
<script src="/blog/photoswipe/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>



<script type="text/x-mathjax-config">
    MathJax.Hub.Config({"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50) },
        tex2jax: { inlineMath: [ ["$", "$"], ["\\(","\\)"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno",skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']},
        TeX: {  noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } }, Macros: { href: "{}" } },
        messageStyle: "none"
    });
</script>
<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>



<!-- Google Analytics -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-YMJ8CBH8F7"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-YMJ8CBH8F7');
</script>
<!-- End Google Analytics -->


</html>
